Saves an array of BarcodeData objects to an XML file.
public static void Save(string fileName,BarcodeData[] data)
Public Overloads Shared Sub Save( _ByVal fileName As String, _ByVal data() As Leadtools.Barcode.BarcodeData _)
public:static void Save(String^ fileName,Leadtools.Barcode.array<BarcodeData^>^ data)
fileName
Name of the XML file to create
data
An array of BarcodeData objects to save.
The load/save methods are provided as helper methods for the user. The BarcodeEngine, BarcodeReader and BarcodeWriter do not use these methods internally. data can be null (Nothing is VB). This is the equivalent of saving an empty array.
To load the data previously saved into an XML file, use BarcodeData.Load(string fileName).
To save and load data to an XML stream, use BarcodeData.Save(Stream stream, BarcodeData[] data) and BarcodeData.Load(Stream stream).
This example reads all the barcodes in an image, saves the data to an XML disk file. It will then load the data from this XML and print out the values.
using Leadtools;using Leadtools.Codecs;using Leadtools.Forms;using Leadtools.Barcode;using Leadtools.ImageProcessing;public void BarcodeData_LoadSaveExample(){string imageFileName = Path.Combine(LEAD_VARS.ImagesDir, "Barcode1.tif");string xmlFileName = Path.Combine(LEAD_VARS.ImagesDir, "MyBarcodes.xml");// Create a Barcode engineBarcodeEngine engine = new BarcodeEngine();// Load the imageusing (RasterCodecs codecs = new RasterCodecs()){using (RasterImage image = codecs.Load(imageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1)){// Read all the barcodesBarcodeData[] barcodes = engine.Reader.ReadBarcodes(image, LogicalRectangle.Empty, 0, null);// Print out the barcodes we foundConsole.WriteLine("{0} barcodes found", barcodes.Length);for (int i = 0; i < barcodes.Length; i++){BarcodeData barcode = barcodes[i];Console.WriteLine(" {0} - {1} - {2}", i + 1, barcode.Symbology, barcode.Value);}Console.WriteLine("-----------------");// Save the barcodes to an XML fileBarcodeData.Save(xmlFileName, barcodes);// Now load the data back and print them outbarcodes = BarcodeData.Load(xmlFileName);Console.WriteLine("{0} barcodes loaded", barcodes.Length);for (int i = 0; i < barcodes.Length; i++){BarcodeData barcode = barcodes[i];Console.WriteLine(" {0} - {1} - {2}", i + 1, barcode.Symbology, barcode.Value);}}}}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.FormsImports Leadtools.BarcodeImports Leadtools.ImageProcessingPublic Sub BarcodeData_LoadSaveExample()Dim imageFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Barcode1.tif")Dim xmlFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "MyBarcodes.xml")' Create a Barcode engineDim engine As New BarcodeEngine()' Load the imageUsing codecs As New RasterCodecs()Using image As RasterImage = codecs.Load(imageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1)' Read all the barcodesDim barcodes() As BarcodeData = engine.Reader.ReadBarcodes(image, LogicalRectangle.Empty, 0, Nothing)' Print out the barcodes we foundConsole.WriteLine("{0} barcodes found", barcodes.Length)For i As Integer = 0 To barcodes.Length - 1Dim barcode As BarcodeData = barcodes(i)Console.WriteLine(" {0} - {1} - {2}", i + 1, barcode.Symbology, barcode.Value)NextConsole.WriteLine("-----------------")' Save the barcodes to an XML fileBarcodeData.Save(xmlFileName, barcodes)' Now load the data back and print them outbarcodes = BarcodeData.Load(xmlFileName)Console.WriteLine("{0} barcodes loaded", barcodes.Length)For i As Integer = 0 To barcodes.Length - 1Dim barcode As BarcodeData = barcodes(i)Console.WriteLine(" {0} - {1} - {2}", i + 1, barcode.Symbology, barcode.Value)NextEnd UsingEnd UsingEnd SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
